#include<bits/stdc++.h>
using namespace std;
const int maxn=1e6+5;
struct node
{
    int mx,num,sum;
};
int n,q,cnt;
string s;
vector<node> tr[maxn<<2];
inline node f(int id,int x)
{
    int sz=tr[id].size();
    if(x<sz) return tr[id][x];
    else return (node){tr[id][sz-1].mx+x-(sz-1),0,tr[id][sz-1].sum+x-(sz-1)};
}
void build(int id,int l,int r)
{
    tr[id].resize(r-l+2);
    if(l==r)
    {
        if(s[l]=='0')
        {
            tr[id][0]=(node){1,1,0};
            tr[id][1]=(node){1,0,0};
        }
        else
        {
            tr[id][0]=(node){1,0,1};
            tr[id][1]=(node){2,0,2};
        }
        return;
    }
    int mid=(l+r)>>1;
    build(id<<1,l,mid);
    build(id<<1|1,mid+1,r);
    node dl,dr;
    for(int i=0;i<=r-l+1;i++)
    {
        dl=f(id<<1,i);
        dr=f(id<<1|1,dl.sum);
        tr[id][i]=(node){max(dl.mx,dr.mx),dl.num+dr.num,dr.sum};
    }
}
int dt[105],ans;
void query(int id,int l,int r,int x,int y)
{
    if(l>=x && r<=y)
    {
        dt[++cnt]=id;
        return;
    }
    int mid=(l+r)>>1;
    if(x<=mid) query(id<<1,l,mid,x,y);
    if(y>mid) query(id<<1|1,mid+1,r,x,y);
}
int main()
{
    freopen("good.in","r",stdin);
    freopen("good.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    node d,dl,dr;
    int l,r;
    cin>>n>>q>>s;
    s=" "+s;
    build(1,1,n);
    while(q--)
    {
        cin>>l>>r;
        cnt=0,d=(node){0,0,0};
        query(1,1,n,l,r);
        for(int i=1;i<=cnt;i++)
        {
            dl=d,dr=f(dt[i],d.sum);
            d=(node){max(dl.mx,dr.mx),dl.num+dr.num,dr.sum};
        }
        //cout<<d.num+d.mx-d.sum<<'\n';
        ans^=(d.num+d.mx-d.sum);
    }
    cout<<ans<<'\n';
    return 0;
}
